import pygame
from Map import Map

class Music():
    def __init__(self, filename):
        self.filename = filename
        # 初始化音乐混合器
        pygame.mixer.init()
        # 加载音乐
        pygame.mixer.music.load(self.filename)

    def play(self):
        # 播放音乐
        pygame.mixer.music.play()

    def stop(self):
        pygame.mixer.music.stop()

    def setVolume(self):
        pygame.mixer.music.set_volume(Map.volume/100)


class BgmMusic():
    def __init__(self, filename):
        self.filename = filename
        # 初始化音乐混合器
        pygame.mixer.init()
        # 加载音乐
        self.bgm = pygame.mixer.Sound(self.filename)
    def stop(self):
        self.bgm.stop()

    def setVolume(self):
        print(Map.volume)
        self.bgm.set_volume(Map.volume/100)

    def play(self):
        # 播放音乐
        self.bgm.play(-1)